//
//  GoodsModel.swift
//  E-CycleForShop
//
//  Created by enghou on 17/3/14.
//  Copyright © 2017年 xyxorigation. All rights reserved.
//

import UIKit

class DecreaseItem : NSObject{
    var type : String = ""
    var price : Int = 0
    init(source : Dictionary<String,Any>) {
        super.init()
        if let typ = source["type"] as? String {
            type = typ
        }
        if let pric = source["price"] as? Int {
            price = pric
        }
    }
}

class GoodsModel: BaseModel {
    var goodsID : Int = -1
    var basePrice : Int = -1 //基础价格
    var decreaseItems : Array<DecreaseItemModel> = []
    override init(source sourceDt: Dictionary<String, Any>?) {
        super.init(source: sourceDt)
        if let dataDic = self.data as? Dictionary<String,Any?> {
            if let base = dataDic["erecycleBase"] as? Dictionary<String,Any>{
                if let id = base["id"] as? Int {
                    goodsID = id
                }
                if let price = base["price"] as? Int {
                    basePrice = price
                }
            }
            if let list = dataDic["deductMoneyList"] as? Array<Dictionary<String,Any>> {
                for item in list {
                    let itm = DecreaseItemModel.init(source: item)
                    if itm.kind == 1 {
                        decreaseItems.append(itm)
                    }
                }
            }
        }
    }
}
